﻿using System;
using System.Collections;
using System.Text;

namespace MPMovieCatalog.Domain
{
    [Serializable()]
    public class ShareFile : NamedEntity
    {
        public ShareFile() { }

        public ShareFile(string name, string path, string cdLabel)
        {
            Name = name.StartsWith((@"\")) ? name.Substring(1, name.Length - 1) : name;
            Path = path.EndsWith(@"\") ? path : path + @"\";
            CDLabel = cdLabel;
        }

        public ShareFile(long id, string name, string path, string cdLabel)
            : this(name, path, cdLabel)
        {
            Id = id;
        }

        public string Path { get; set; }

        public string CDLabel { get; set; }

        public string StorageName
        {
            get
            {
                return Name.StartsWith((@"\")) ? Name : @"\" + Name;
            }
        }

        public string StoragePath
        {
            get
            {
                return Path.EndsWith(@"\") ? Path.Substring(0, Path.Length - 1) : Path;
            }
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            if (Path != string.Empty)
            {
                sb.Append(Path);
            }
            sb.Append(Name);
            return sb.ToString();
        }
    }
}
